package com.xxx.pojo;

/**
 * 一个Location代表世界的一个经纬坐标
 * @author 周祥
 */
public class Location {
	
	/**
	 * 地址
	 */
	private String addressname;
	
	/**
	 * 纬度
	 */
	private Float lat;
	
	/**
	 * 经度
	 */
	private Float lng;
	
	public Location() {
		super();
	}

	public Location(Float lng,Float lat) {
		super();
		this.lat = lat;
		this.lng = lng;
	}
	
	private static final float DEFAUL_LAT = 200;
	private static final float DEFAUL_LNG = 200;
	/**
	 * 判断该地址是否是一个无效地址
	 * @param location
	 * @return
	 */
	public static  boolean isInvliadLocation(Location location){
		if(location == null){
			return true;
		}
		
		if(location.getLng() == null || location.getLat() == null){
			return true;
		}
		
		if(location.getLat() == DEFAUL_LAT && location.getLng() == DEFAUL_LNG){
			return true;
		}
		return false;
	}

	public Float getLat() {
		return lat;
	}

	public void setLat(Float lat) {
		this.lat = lat;
	}

	public Float getLng() {
		return lng;
	}

	public void setLng(Float lng) {
		this.lng = lng;
	}

	
	public String getAddressname() {
		return addressname;
	}

	public void setAddressname(String addressname) {
		this.addressname = addressname;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((lat == null) ? 0 : lat.hashCode());
		result = prime * result + ((lng == null) ? 0 : lng.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Location other = (Location) obj;
		if (lat == null) {
			if (other.lat != null)
				return false;
		} else if (!lat.equals(other.lat))
			return false;
		if (lng == null) {
			if (other.lng != null)
				return false;
		} else if (!lng.equals(other.lng))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Location [lat=" + lat + ", lng=" + lng + "]";
	}

}